package com.study.example.controller;

import com.study.example.component.RandomComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.study.example.service.redis.IRedisService;

/**
 * Created by User on 2017/9/13.
 */
@RestController
public class RedisCacheController {

    private static final Logger log = LoggerFactory.getLogger(RedisCacheController.class);

    @Autowired
    private RandomComponent randomComponent;

    @Autowired
    private IRedisService redisService;

    

    @RequestMapping("setCache")
    public void setCache() {
        log.info("set cache");
        redisService.set("cache1", randomComponent.nextInt() + "");

    }

    @RequestMapping("getCache")
    public void getCache() {
        log.info("get cache");
        String cache1 = redisService.get("cache1");
        log.info(cache1);

    }


}
